from itsdangerous import TimedJSONWebSignatureSerializer as Serializer

#########生成token########################
user_dict = {'user_id': 168, "email": "123@qq.com"}
# 密钥
secret_key = "jiajia"

ser = Serializer(secret_key, expires_in=60 * 5)  # itsdangerous对象
print(ser)
token = ser.dumps(user_dict)  # 二进制数据
token = token.decode()

########################################################
# 解析token
user_dict_resolv = ser.loads(token)
print(user_dict_resolv)  # {'user_id': 168, 'email': '123@qq.com'}
